<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>日志管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnExport").click(function(){
				top.$.jBox.confirm("确认要导出本页数据吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						$("#searchForm").attr("action","${ctx}/ins/insLog/export?pagination=true");
						$("#searchForm").submit();
						$("#searchForm").attr("action","${ctx}/ins/insLog/");
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
			});
			$("#btnAllExport").click(function(){
				top.$.jBox.confirm("确认要导出全部数据吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						$("#searchForm").attr("action","${ctx}/ins/insLog/export");
						$("#searchForm").submit();
						$("#searchForm").attr("action","${ctx}/ins/insLog/");
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
			});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function dataForm(logId,extend){
			var url = "${ctx}/ins/insLog/form?id="+logId;
			top.$.jBox.open("iframe:"+url, "日志详情--"+extend,860,$(top.document).height()-120,{
                buttons:{"关闭":true}, bottomText:"日志详情",submit:function(v, h, f){
                    /* var code;
                    if (v=="ok"){
                    	// 执行保存
                        //loading('正在提交，请稍等...');
                    	var flag = h.find("iframe")[0].contentWindow.submitForm();
                    	if(flag){
                    		location.reload();
                    	}
                        return false;
                    } */
                }, loaded:function(h){
                    $(".jbox-content", top.document).css("overflow-y","hidden");
                }
            });
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ins/insLog/">日志列表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="insLog" action="${ctx}/ins/insLog/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li>
				<label>表名称：</label>
				<input type="text" name="table.name" value="${insLog.table.name}" class="input-medium"/>
			</li>
			<li><label>模块：</label>
				<select name="module" class="input-medium" data-value="${insLog.module}">
					<option value="">---请选择---</option>
					<option value="1" <c:if test="${insLog.module==1}">selected</c:if>>数据表</option>
					<option value="2" <c:if test="${insLog.module==2}">selected</c:if>>数据</option>
				</select>
			</li>
			<li>
				<label>索引：</label>
				<input type="text" name="index" value="${insLog.index}" class="input-medium"/>
			</li>
			<li><label>操作类型：</label>
				<select name="type" class="input-medium" data-value="${insLog.type}">
					<option value="">---请选择---</option>
					<option value="1" <c:if test="${insLog.type==1}">selected</c:if>>修改</option>
					<option value="2" <c:if test="${insLog.type==2}">selected</c:if>>删除</option>
					<option value="3" <c:if test="${insLog.type==3}">selected</c:if>>打印</option>
					<option value="4" <c:if test="${insLog.type==4}">selected</c:if>>绑定模板</option>
					<option value="5" <c:if test="${insLog.type==5}">selected</c:if>>解绑模板</option>
					<option value="6" <c:if test="${insLog.type==6}">selected</c:if>>创建</option>
					<option value="7" <c:if test="${insLog.type==7}">selected</c:if>>填报</option>
					<option value="8" <c:if test="${insLog.type==8}">selected</c:if>>增加人员</option>
					<option value="9" <c:if test="${insLog.type==9}">selected</c:if>>移除人员</option>
					<option value="10" <c:if test="${insLog.type==10}">selected</c:if>>分配权限</option>
				</select>
			</li>
			<li><label>创建时间从：</label>
    				<input name="dateFrom" id="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
    					value="${insLog.dateFrom}"
    					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true,maxDate:'#F{$dp.$D(\'endTime\')}'});"/>
   			</li>
   			<li><label>创建时间到：</label>
   				<input name="dateTo" id="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
   					value="${insLog.dateTo}"
   					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true,minDate:'#F{$dp.$D(\'startTime\')}'});"/>
   			</li>
   			<li><label>操作人：</label>
   				<sys:treeselect id="manager" name="createBy.id" value="${insLog.createBy.id}" labelName="createBy.name" labelValue="${insLog.createBy.name}"
    					title="用户" url="/sys/office/treeData?type=3" cssClass="input-small" allowClear="true" notAllowSelectParent="true"/>
   			</li>
			<li class="btns">
				<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
				<input id="btnExport" class="btn btn-primary" type="button" value="导出本页"/>
				<input id="btnAllExport" class="btn btn-primary" type="button" value="导出全部"/>
			</li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>索引</th>
				<th>表名称</th>
				<th>模块</th>
				<th>操作类型</th>
				<th>数据摘要</th>
				<th>操作日期</th>
				<th>操作人</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="insLog">
			<tr>
				<td>
					<c:choose>
						<c:when test="${insLog.type == 4 || insLog.type == 5}">
							${insLog.data}
						</c:when>
						<c:otherwise>
							${insLog.index}
						</c:otherwise>
					</c:choose>
				</td>
				<td>
					<c:choose>
						<c:when test="${insLog.type == 4 || insLog.type == 5 || insLog.type == 8 || insLog.type == 9}">
							${insLog.table.name}
						</c:when>
						<c:otherwise>
							<a href="javascript:void(0);" onclick="dataForm('${insLog.id}','数据表标识：'+'${insLog.table.tableId}'+'数据表版本：'+'${insLog.table.version}')">
									${insLog.table.name}
							</a>
						</c:otherwise>
					</c:choose>
				</td>
				<td>
					<c:choose>
						<c:when test="${insLog.module==1}">
							数据表
						</c:when>
						<c:when test="${insLog.module==2}">
							数据
						</c:when>
						
					</c:choose>
				</td>
				<td>
					<c:choose>
						<c:when test="${insLog.type==1}">
							修改
						</c:when>
						<c:when test="${insLog.type==2}">
							删除
						</c:when>
						<c:when test="${insLog.type==3}">
							打印
						</c:when>
						<c:when test="${insLog.type==4}">
							绑定模板
						</c:when>
						<c:when test="${insLog.type==5}">
							解绑模板
						</c:when>
						<c:when test="${insLog.type==6}">
							创建
						</c:when>
						<c:when test="${insLog.type==7}">
							填报
						</c:when>
						<c:when test="${insLog.type==8}">
							增加人员
						</c:when>
						<c:when test="${insLog.type==9}">
							移除人员
						</c:when>
						<c:when test="${insLog.type==10}">
							分配权限
						</c:when>
					</c:choose>
				</td>
				<td>
					<c:if test="${insLog.type==8 || insLog.type==9}">
						${insLog.data}
					</c:if>
				</td>
				<td>
					<fmt:formatDate value="${insLog.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${insLog.createBy.name}
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>